<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:body>
       <h:form id="frmUsers">
           
           <p:commandButton value="Nuevo Usuario"
                            update=":frmNewUser:dlgNewUser"
                            oncomplete="dlgNewUser.show();"
                            icon="ui-icon-plus"
                            title="Nuevo Usuario"
                            />
           
           <p:commandButton value="Activar Usuarios"
                            update=":frmActiveUser:dlgActiveUser"
                            oncomplete="dlgActiveUser.show();"
                            icon="ui-icon-plus"
                            title="Activar Usuarios"
                            actionListener="#{userBean.inactiveUsers(true)}"
                            />
           <br/>
           <br/>
           <p:dataTable id="dtUsers"
                        var="user" value="#{userBean.users}" 
                         emptyMessage="No se encontraron registros"
                         paginator="true" rows="10"  
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                         rowsPerPageTemplate="5,10,15">
               
               <p:column headerText="Código">
                   <h:outputText value="#{user.usrCode}"/>
               </p:column>
                <p:column headerText="Nombres">
                    <h:outputText value="#{user.usrName}"/>
               </p:column>
               <p:column headerText="Apellidos">
                   <h:outputText value="#{user.usrLstn}"/>
               </p:column>
               <p:column headerText="Perfil">
                   <h:outputText value="#{user.profiles.prfName}"/>
               </p:column>
               <p:column headerText="Último Ingreso">
                   <h:outputText value="#{user.usrLastLogin}"/>
               </p:column>
               <p:column headerText="Activo" 
                         style="text-align: center;">
                   <p:selectBooleanCheckbox value="#{user.usrActv}"
                                            disabled="true"/>
               </p:column>
               
               <p:column style="text-align: center;">
                   
                   <p:commandButton title="Editar"
                                    update=":frmEditUser:dlgEditUser"
                                    oncomplete="dlgEditUser.show();"
                                    actionListener="#{userBean.selectUser(user.usrCode)}"
                                    icon="ui-icon-arrowrefresh-1-n"
                                    />
                   <p:commandButton title="Eliminar"
                                    update=":frmDeleteUser:dlgDeleteUser"
                                    oncomplete="dlgDeleteUser.show();"
                                    actionListener="#{userBean.selectUser(user.usrCode)}"
                                    icon="ui-icon-circle-close"
                                    />
               </p:column>
               
           </p:dataTable>
       </h:form>
    </h:body>
</html>

